package ankang.oop1;

public class Person {
    String name;
    int age;
    char gender;
    int appetite;//吃几碗饭
    double sleepHours;

    Person(){
        name="";
        age=0;
        gender='?';
    }
    Person(int a){
        age=a;
    }
    Person(int a, char g){
        age=a;
        gender=g;
    }

    //this.成员变量： 调用成员变量
    Person(String name, int a){
        this(name,a,'?');
    }


    Person(String name, int age, char gender){
        //this可以区分成员变量和方法参数
        this.name=name;
        this.age=age;
        this.gender = gender;
    }




    //调用一次eat将appetite加1， 如果appetite>=2就返回true，否则返回false
    public boolean eat(){
        appetite++;
        if(appetite>=2){
            return true;
        }
        return false;
    }


    //调用一次sleep将sleepHours加1， 如果appetite>=7.5就返回true，否则返回false
    boolean sleep(){
        sleepHours++;
        if(appetite>=7.5){
            return true;
        }
        return false;
    }

    String getAllMsg(){
        return "name:"+name+","+"age:"+age+","+"gender:"+gender+","+"appetite:"+appetite+","+"sleepHours:"+sleepHours;
    }

}
